<?php
require_once("../lib/DbWrapper.class.php");
require("../libs/Smarty.class.php");
$smarty = new Smarty;

DbWrapper::dbChoice();
//DELETE命令による物理削除
/*
//クエリを送信する
$id = $_GET["id"];
$sql = "SELECT count(*) FROM reply WHERE comment_id = '".$id."'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);

if($row[0] >0){
    //内部結合
    $sql = "DELETE comment,reply
            FROM comment,reply
            WHERE comment.id =reply.comment_id
            AND comment.id ='".$id."'";
}else{
    $sql = "DELETE FROM comment WHERE id ='".$id."'";
}
*/
//commentテーブルに外部結合
$id = $_GET["id"];
$sql = "DELETE comment,reply
        FROM comment LEFT JOIN reply
        ON comment.id = reply.comment_id
        WHERE comment.id ='" . $id. "'";
mysql_query($sql);

$smarty->display("comment_delete.tpl");